<template>
    <div class="component-checkbox-group clear-float">
        <div v-for="(item, k) in items" class="item" :key="k" :class="{'active': k === active || (active.length && active.indexOf(k) != -1)}" @click="$emit('onactive', k)">{{item}}</div>
    </div>
</template>

<style lang="less" scoped>

    @import '../style/variable';

    .component-checkbox-group{
        padding-left: 1.5rem;
        padding-bottom: .7rem;
        .item{
            margin-right: 1.5rem;
            width: 7.5rem;
            float: left;
            height: 3.3rem;
            line-height: 3.3rem;
            text-align: center;
            border-radius: .2rem;
            background-color: @color-bg-light-gray;
            white-space: nowrap;
            overflow: hidden;

            &:nth-child(1n+5){
                margin-top: 1.5rem;
            }

            &.active{
                color: @color-orange;
                background-color: @color-bg-orange;
                position: relative;
                &:after{
                    content: '';
                    display: block;
                    position: absolute;
                    width: 2.2rem;
                    height: 2.2rem;
                    bottom: 0;
                    right: 0;
                    background-image: url("../assets/option-active.png");
                    background-size: contain;
                    background-position: right bottom;
                    background-repeat: no-repeat;
                }
            }
        }
    }
</style>

<script>
    export default {
        props: ['items', 'active']
    }
</script>